import { createHtml, screenshotByFile  } from 'alemonjs'
import { AppName,DirPath} from '../config.js';
import fs,{ writeFileSync } from 'fs'
import art from 'art-template'
import path from 'path';
import yaml from 'js-yaml';
/**
 * @param directory 文件
 * @param data 数据
 * @returns
 */
export function oImages(directory: string, data: any = {}) {
    const { template, AdressHtml } = createHtml(AppName, `${DirPath}${directory}`)
    writeFileSync(AdressHtml, art.render(template, data))
    return screenshotByFile(AdressHtml, {
      SOptions: { type: 'jpeg', quality: 90 },
      tab: 'body',
      timeout: 2000
    })
  }
  
export const __PATH = {
  help: path.join(DirPath, 'resources', 'data', 'help', 'help.yaml'), 
};
// console.log(__PATH.player);
let yamltype ={
"1":__PATH.help,
}
 /**
 *
 * @param num [1:help]
 * @returns 
 */
export async function Read_yaml(num:number){
  try {
    const fileContents = fs.readFileSync(yamltype[num], 'utf8');
    const data = yaml.load(fileContents);
    return data;
  } catch (error) {
    console.log(error);
  }
}
  